home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 10 / 010.d81 / trial error (.txt) < prev    next >
Commodore BASIC  |  2022-08-26  |  1KB  |  39 lines

  1. 10 rem ***************************
  2. 20 rem *    -trial and error-    *
  3. 30 rem *     shlomo ginsberg     *
  4. 35 rem * use for any expression  *
  5. 40 rem *    by changing lines    *
  6. 45 rem *       150 and 190       *
  7. 50 rem ***************************
  8. 60 poke53280,11:poke53281,0
  9. 70 print"[147]";
  10. 80 print"            trial and error           ";
  11. 90 print"           shlomo ginsberg, 1984          "
  12. 100 input" initial point        ";x
  13. 110 input" initial step         ";s
  14. 120 input" convergence criterion";c
  15. 130 rem
  16. 140 i%=0:k=1
  17. 150 y=x*x*x-6*x*x+11*x-6
  18. 160 print"[147]cycle=";i%;"x=";x;"y=";y
  19. 170 ifabs(y)<cthen280
  20. 180 x=x+s:goto260
  21. 190 y=x*x*x-6*x*x+11*x-6
  22. 200 print"cycle=";i%;"x="x;"y=";y
  23. 210 ifabs(y)<cthen280
  24. 220 j%=sgn(y1)*sgn(y)
  25. 230 ifj%<>1thenk=0.5
  26. 240 s=k*j%*s
  27. 250 x=x+s
  28. 260 y1=y:i%=i%+1
  29. 270 goto190
  30. 280 print"             that's all folks           "
  31. 290 rem    stop
  32. 300 :
  33. 60000 print"do it again?"
  34. 60010 poke198,0:wait198,1:getk$:ifk$<>"y"andk$<>"n"thenpoke53280,rnd(1)*15:goto60010
  35. 60020 ifk$="y"thenrun
  36. 63000 rem   connect back to loadstar
  37. 63010 print"[147]load"chr$(34)"payload"chr$(34)",8":print"run"
  38. 63020 poke631,13:poke632,13:poke198,2:end
  39.